package com.dss.auto_deploy.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dss.auto_deploy.domain.AdmDb;
import com.dss.auto_deploy.dto.AdmDbAddDto;
import com.dss.auto_deploy.dto.AdmDbPageDto;
import com.dss.auto_deploy.dto.AdmDbUpdateDto;
import com.dss.auto_deploy.vo.AdmDbVo;
import org.springframework.web.multipart.MultipartFile;

import java.sql.Connection;
import java.util.List;

/**
* @Description:数据库Service
* @author dongshoushan
* @date 2022-10-29 13:00:40
*/
public interface IAdmDbService  extends IService<AdmDb> {
    /**
    * 新增数据库
    * @param admDbAddDto
    * @return
    */
    int insert(AdmDbAddDto admDbAddDto);

    /**
    * 修改数据库
    * @param admDbUpdateDto
    * @return
    */
    int update(AdmDbUpdateDto admDbUpdateDto) throws Exception;

    /**
    * 批量删除数据库
    * @param ids
    * @return
    */
    void deleteBatch(Long[] ids);

    /**
    * 数据库查询
    * @param dto
    * @return List<AdmDb>
    */
    Page<AdmDbVo> list(AdmDbPageDto dto) throws InterruptedException;

    void installMysql(String ids,String tempPath, MultipartFile mysqlFile) throws InterruptedException;
    void installPostgres(String ids,String tempPath, MultipartFile file) throws InterruptedException;

    void installMongo(String ids, String tempPath, MultipartFile mongoFile, MultipartFile mongoclientFile,String clientMountPath);

    void installRedis(String ids, String tempPath, MultipartFile redisFile);

    /**
     * 执行sql文件
     * @param dbId
     * @param databaseName
     */
    void executeSql(String dbId, String databaseName,Long projectId);

    List<AdmDbVo> getByType(String type,String name);
    List<AdmDb> getAll();

    Connection getMysqlConnection(AdmDb admDb) throws Exception;

    Connection getPostgresConnection(AdmDb admDb) throws Exception;
}
